function Player()
{

	//speeds are pixels per second... could cause issues on different size devices. we'll revisit
	this.gravity = 60;
	this.jumpSpeed= 2100;
	this.moveSpeed = 400;
	this.xvel = 0;
	this.yvel = 0;
	this.width = 48;
	this.height = 144;
	this.x = 200;
	this.y = window.innerHeight-this.height;
	this.movingLeft = false;
	this.jumping = false;
	this.movingRight = false;
	this.falling = false; 
	this.grounded =false; 
	this.image = new Image();
	this.image.src = "pixelsheet.png";
	this.drawParams = {"sx": 0, "sy" : 0, "sw" : 24, "sh" : 72 };
	this.frameSpeed = .1;
	this.imageWidth = 24;
	this.imageHeight = 72;
	//this.clip= 0;
	this.update = function(){
		
		animFrame = Math.floor(time / this.frameSpeed) % 4 +1;
		
		if(this.movingRight && this.movingLeft)
		{
			this.xvel = 0;
			this.drawParams["sx"] = 0;
		}
		else if(this.movingLeft)
		{
			this.xvel = -this.moveSpeed;
			this.drawParams["sy"] = this.imageHeight; 
			this.drawParams["sx"] = animFrame * this.imageWidth;
		}
		else if(this.movingRight)
		{
			this.xvel = this.moveSpeed; 
			this.drawParams["sy"] = 0;
			this.drawParams["sx"] = animFrame * this.imageWidth;
		}
		else
		{
			this.drawParams["sx"] = 0;
			this.xvel = 0;
		}
		//if the player is moving upwards, they are jumping
		//if they are moving downards, they aren't.
		//if they are still, they are either at apex, or grounded
		// console.log(this.yvel, this.jumping, this.grounded);
		
		if(this.yvel < 0) //moving up
		{
			this.jumping = true;
			this.grounded = false;
		}
		if(this.yvel == 0 && !this.jumping)
		{
			this.grounded = true;
		}
		if(this.yvel == 0 ) //ground or apex
		{
			this.jumping = false;
		} 

		if(this.yvel > 0)//falling
		{
			this.jumping = false;
		}

		this.yvel += this.gravity ; 

		
	};

	this.headbutt = function()
	{

	}
}
